package com.ozo.cloud.common.core.exception;

import com.ozo.cloud.common.base.exception.AbstractExceptionEnum;
import com.ozo.cloud.common.base.exception.CommonExceptionEnum;
import lombok.Data;

/**
 * 业务异常
 *
 * @author qiangesoft
 * @date 2024-06-28
 */
@Data
public class ServiceException extends RuntimeException {

    private Integer code;

    private String errorMessage;

    public ServiceException(String errorMessage) {
        super(errorMessage);
        this.code = CommonExceptionEnum.INTERNAL_SERVER_ERROR.getCode();
        this.errorMessage = errorMessage;
    }

    public ServiceException(Integer code, String errorMessage) {
        super(errorMessage);
        this.code = code;
        this.errorMessage = errorMessage;
    }

    public ServiceException(AbstractExceptionEnum errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.errorMessage = errorCode.getMessage();
    }

}